package com.wpre.lotterysystem.dao.mapper;

import com.wpre.lotterysystem.controller.param.PageParam;
import com.wpre.lotterysystem.dao.dataobject.ActivityDO;
import com.wpre.lotterysystem.service.enums.ActivityStatusEnum;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-12-21
 * Time: 18:28
 */
@Mapper
public interface ActivityMapper {
    /**
     * 插入活动信息
     *
     * @param activityDO
     * @return
     */
    @Insert("insert into activity (activity_name,description,status) " +
            " values(#{activityName},#{description},#{status}) ")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(ActivityDO activityDO);


    //活动列表
    @Select("select * from activity order by id desc limit #{offset},#{pageSize}")
    List<ActivityDO> selectActivityList(Integer offset, Integer pageSize);

    //查询活动总量
    @Select("select count(*) from activity")
    int count();

    //根据id查询活动
    @Select("select * from activity where id = #{id}")
    ActivityDO selectActivityById(@Param("id") Long activityId);

    //扭转活动的状态
    @Update("update activity set status = #{status} where id = #{id}")
    void updateStatus(@Param("id")Long activityId,@Param("status") String status);

}
